/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.webapp.form.contact;

import com.blandware.atleap.webapp.form.BaseForm;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>ActionForm bean containing information to send "contact us" mail message</p>
 * <p><a href="ContactForm.java.html"><i>View Source</i></a></p>
 *
 * @author Sergey Zubtsovskiy <a href="mailto:sergey.zubtsovskiy@blandware.com">&lt;sergey.zubtsovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.5 $ $Date: 2006/08/03 10:08:05 $
 * @struts.form name="contactForm"
 */
public class ContactForm extends BaseForm {

	protected String userName;
	protected String email;
	protected String message;
	protected String preview;

	/**
	 * Creates the new instance of ContactForm
	 */
	public ContactForm() {
	}

	/**
	 * Returns name of user who sends this message
	 *
	 * @return Name of user
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * Sets name of user who sends this message
	 *
	 * @param userName Name of user to set
	 * @struts.validator type="required"
	 * @struts.validator-args arg0resource="contact.form.userName"
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * Gets e-mail address of user who sends message to us
	 *
	 * @return E-mail of user
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Sets e-mail address of user, who sends message to us
	 *
	 * @param email E-mail of user to set
	 * @struts.validator type="required"
	 * @struts.validator type="email"
	 * @struts.validator-args arg0resource="contact.form.email"
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Gets message to send
	 *
	 * @return Message to send
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Sets message to send
	 *
	 * @param message Message to send
	 * @struts.validator type="required"
	 * @struts.validator-args arg0resource="contact.form.message"
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * Returns non-null value if 'preview' button has been pressed
	 *
	 * @return non-null value if user wants to preview message to be sent
	 */
	public String getPreview() {
		return preview;
	}

	/**
	 * Sets value of preview field
	 *
	 * @param preview Value to set
	 */
	public void setPreview(String preview) {
		this.preview = preview;
	}

	/**
	 * Resets all properties to their default values
	 *
	 * @param mapping The ActionMapping used to select this instance
	 * @param request The non-http request we are proceeding
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		userName = null;
		email = null;
		message = null;
		preview = null;
	}

	/**
	 * Form validation
	 *
	 * @param mapping The ActionMapping used to select this instance
	 * @param request The non-http request we are proceeding
	 * @return Instance of ActionErrors contains all validation errors
	 */
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		return errors;
	}
}